<div class="page-header">
    <h2><b>Chuyên mục: Hỏi đáp</b></h2>
</div>
<div class="panel panel-info" style="padding-bottom: 10px; padding-top: 5px;">
    <h4 style="padding-left: 10px;"><strong>Có thắc mắc cần giải đáp, hãy đặt câu hỏi?</strong></h4>
    <div class=" text-center">
        <?php echo form_open('chuyenmuc-hoidap/cauhoi') ?>
        <button class="btn btn-danger">Tạo câu hỏi</button>
        <?php echo form_close(); ?>
    </div>
</div>
<div class="panel panel-info" >
    <div class="text-center">
        <p><?php echo $link; ?></p>
    </div>
    <?php
    if (is_array($records)) {
        if (!empty($records)) {
            foreach ($records as $data) {
                ?>
                <div class="panel panel-warning" style="margin: 5px;">
                    <div  style="margin-top:3%; margin-left: 1%; float: left;">
                        <img src="<?php echo base_url(); ?>/image/hoidap/question<?= rand(1, 3) ?>.png" height="80" width="80">
                    </div>
                    <div style="margin-left: 20%;" >    
                        <h3>
                            <strong>
                                <?php
                                if (strlen($data->tieude) > 50) {
                                    $tieude = substr($data->tieude, 0, 50);
                                    echo substr($tieude, 0, strrpos($tieude, ' ')) . ' ...';
                                } else {
                                    echo $data->tieude . ' ...';
                                }
                                ?>
                            </strong>
                        </h3>
                        <p>
                            <small>
                                <?php
                                if (strlen($data->noidung) > 50) {
                                    $noidung = substr($data->noidung, 0, 50);
                                    echo substr($noidung, 0, strrpos($noidung, ' ')) . ' ...';
                                } else {
                                    echo $data->noidung . ' ...';
                                }
                                ?>
                            </small>
                        </p>
                    </div>
                    <div style=" margin-bottom: 1%; margin-left: 80%;">
                        <?php echo form_open('hoidap/hoidap/show_id'); ?>
                        <input type="hidden" name="id_hoidap" value="<?= $data->id; ?>">
                        <input type="submit" class="btn btn-info" value="Chi tiết >>">
                        <?php echo form_close(); ?>            
                    </div>
                </div>
                <?php
            }
        } else {
            echo '<div class="text-center"><em>Hiện tại chưa có câu hỏi.</em></div>';
        }
    }
    ?>
    <div class="text-center">
        <p><?php echo $link; ?></p>
    </div>
</div>